package com.design3.graduatethesissys.controller;

import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.design3.graduatethesissys.common.Constants;
import com.google.gson.Gson;

/** 
* @author 作者 罗穆健: 
* @version 创建时间：2020年1月8日 下午7:50:57 
* 类说明 
*/
@Controller
public class Error {

	@RequestMapping(value = "/Login-error")
	public String Error1(ModelMap data,HttpServletRequest request,HttpServletResponse response) {	
//		System.out.println(exception);
		Authentication auth = SecurityContextHolder.getContext().getAuthentication();
		System.out.println(Constants.Loginerror);
		if(auth instanceof AnonymousAuthenticationToken){
			if(Constants.Loginerror == Constants.USERNAMEPSWERROR) {
				data.addAttribute("error1","用户名或密码错误");
				Constants.Loginerror = 0;
			} 
			return "Login";
		}else{
			return "design";
		}		
	}
}
 